<?php
namespace Home\Controller;
// use Think\Controller;
class IndexController extends HomeController 
{
	private $_movie = null;
	private $_model = null;

	public function _initialize()
	{
		$this->_movie = M('movie');
		$this->_model = M('Banner');
	}
    public function index()
    {
    	// var_dump($_SESSION);
    	//轮播图
    	$data = $this->_model->where(array('status'=>array('eq',0)))->limit(5)->select();
    	// var_dump($data);
    	// exit;
    	//轮播图下面的js滚动图
		$list = M()->table('lamp_movie  as  m')->field('m.country,m.id,m.showdate,m.name as mname,i.icon')->join('lamp_img  as  i  on  m.id = i.mid and face=1')->limit(10)->select();
		// var_dump($list);exit;
		//电影top 10
		// $list1 = $this->_movie->limit(10)->select();
		$list1 = M()->table('lamp_movie  as  m')->field('m.id,m.showdate,m.name as mname,i.icon,c.name as cname,c.id as cid')->join('lamp_img  as  i  on  m.id = i.mid and face=1')->join('lamp_category as c on m.cid=c.id')->order('m.id desc')->limit(10)->select();
		// var_dump($list1);exit;


		//正在热映
		$list3 = M()->table('lamp_movie  as  m')->field('m.country,m.id,m.showdate,m.name as mname,i.icon')->join('lamp_img  as  i  on  m.id = i.mid and face=1')->where('m.display=0')->limit(3)->select();
		//即将热映
		$list4 = M()->table('lamp_movie  as  m')->field('m.country,m.id,m.showdate,m.name as mname,i.icon')->join('lamp_img  as  i  on  m.id = i.mid and face=1')->where('m.display=1')->limit(3)->select();
		//特色
		$list5 = M()->table('lamp_movie  as  m')->field('m.country,m.id,m.showdate,m.name as mname,i.icon')->join('lamp_img  as  i  on  m.id = i.mid and face=1')->where('m.display=0')->order('m.id desc')->limit(6)->select();

		//广告图
		$advert = M('advert');
		$list7 = $advert->field('icon,iurl')->where('status=1')->limit(2)->select();
		// var_dump($list7);exit;

		//友情链接
		$friend = M('friend');
		$list6 = $friend->where('status=0')->limit(6)->select();
		// var_dump($list6);exit;

		//首页导航条
		$category = M('category');
		$list2 = $category->where('pid=0')->select();
		// var_dump($list2);exit;

		// var_dump($list);exit;	     	
		//分配变量
		$this->assign('list2',$list2);
		$this->assign('list3',$list3);
		$this->assign('list4',$list4);
		$this->assign('list5',$list5);
		$this->assign('list6',$list6);
		$this->assign('list7',$list7);


		$this->assign('img',$data);//轮播图
		$this->assign('list1',$list1);
		$this->assign('list',$list);
		//加载模板
        $this->display();
    }

    public function about()
    {
         
        $this->display();
    }


}